package com.example.dao.implDao;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.dao.FamilyInfoDao;
import com.example.mapper.FamilyMapper;
import com.example.pojo.EnrollInfo;
import com.example.pojo.FamilyInfo;
import com.example.pojo.dto.FamilyStuDTO;
import com.example.pojo.dto.UserParentInfoDTO;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

@Repository
public class FamilyInfoDaoImpl implements FamilyInfoDao {
    @Resource
    private FamilyMapper familyMapper;
    @Override
    public String addOrUpdateFamilyInfo(FamilyInfo familyInfo) {
        String result = "";
        if(Objects.isNull(familyInfo.getFamilyId())) {
            familyMapper.insert(familyInfo);
            result="添加成功";
        }else{
            familyMapper.updateById(familyInfo);
            result="修改成功";
        }
        return result;
    }

    @Override
    public FamilyInfo selectByChildId(Long childId) {
        return familyMapper.selectById(childId);
    }

    @Override
    public UserParentInfoDTO selectFamilyByStuName(String stuName) {
        return familyMapper.selectFamilyByStuName(stuName);
    }

//    @Override
//    public IPage<FamilyStuDTO> getAllFamilyPage(int currentPage, int limit) {
//        Page<FamilyStuDTO> page=new Page<>(currentPage,limit);
//        familyMapper.selectPage(page);
//        return null;
//    }


}
